Current Version:  2.0 Implements WYSIWIG HTML!
                  (see What's New in Version 2 and Version History)
Last updated:     8 Mar 1995

Silcot's Nisus HTML Janus Macros Version 2.0

Legalese: These macros are free for personal, non-profit, or educational use. The software is provided 'as is' without express or implied warranties.


About these macros

Nisus is a fantastic word processor for HTML writing because styled documents can be served directly, and its search/replace and non-contiguous selection features are outstanding. Here is a set of Nisus macros to assist World Wide Web authors to generate HTML documents. These "janus" macros run unmodified in both version 3.25 and version 4 (NisusWriter).

These macros are designed for an author who is comfortable with HTML tags. There is no reliance on style information whatsoever. Use of styles of course is not precluded. Personally, I find that applying stylenames, and then having these translated to html tags in some way imposes an unnecessary extra step. I prefer to work directly with html and test appearance in a real browser, rather than simulated wysiwyg mode. So I wrote these macros.

If you prefer being able to see the HTML tags as you write HTML, I hope you find these macros useful. If you do use them, please email me at ssilcot@www.unimelb.edu.au. Thanks to all the people who mailed me about earlier releases - your feedback encourages me to continue to support these macros.

New in Version 2: It may be useful to have WYSIWIG visual cues in editing html. Version 2 now optionally supports styled html editing. In styled editing mode, when you run a macro to insert HTML tags, the replacement is made attribute sensitive to the defined character stylenames in the macrosheet. If you prefer working with plain text, you may continue to do so by leaving styled editing turned off. Let me explain this a little more. Text between and including the angle brackets eg. <...> is a HTML tag. Running the macro *Apply HTML Styles will apply the *tagstyle to all such HTML tags regardless of whether styled mode editing is on or off. If you have styled editing mode turned on, the text in-between the opening and closing tags will also have an appropriate style applied "on the fly" by the tag inserting macros where appropriate eg. *H1, or *strong will apply styles, wheras the macros for list items and paragraphs do not.

The macros are distributed with styled editing OFF. If you want to try the styled editing, PLEASE read the documentation on styled mode first (or you might be surprised by the results). Enable styled editing by running the macro named *HTML Styles ON in Macros. To see what the distributed defined styles do, open a copy of a HTML document, run the *Apply HTML Styles macro, and be patient! Then toggle the display of Invisible Text on and off.

Enjoy!


FTP Source and Installation Notes

Here's how to obtain and install the macros:

  1. Download the package

    The package is available for anonymous ftp from ftp://cwis.unimelb.edu.au/pub/tools/mac/ssHTMLNisusMacros2.0.sea.hqx.

    The package, a binhexed self-extracting-archive, contains:

  2. Install keyboard preferences.

    New users:
    This is a once only task. Open the macro file HTML Keyboard Shortcuts Setup. Execute the macro named <aaMake Shortcuts V3> or <aaMake Shortcuts V4> depending on which version of Nisus you use. These assignments can be removed with the macro <aaREMOVE Shortcuts Vn>. The keyboard shortcuts assigned are noted below.
    Users of 1.3 and earlier versions:
    Add your own shortcuts for the new macros listed in Version History.
  3. Customise the macro suite

    Open and Edit the macro file SilcotsHTMLjanusMacros. Customise the macros <aTemplate Footer...> and <aTemplate Header...> (not needed if you prefer to use a stationery document.). See also instructions for customising defined character styles for the HTML tags.

  4. Turn on styled editing (optional)

    If you want to use styled editing, you must run the macro *HTML Styles ON in Macros (The macros are distributed with styled mode editing OFF).

You are now ready to start writing HTML.

Note: The shortcuts in the distribution reflect my preferences, not yours! I have tended to choose an abbreviation of the HTML tag name because I am familiar with the tags. The macros are named so that, usually, the uppercase letters in the name give visual reminder for the distributed shortcuts eg. The macro named <CIte> has shortcut command-option-CI. If you wish to assign different shortcuts, modify <aaMake Shortcuts Vn> as required before running it, or modify them later as required using Nisus' Menu Keys command (Thanks to Jonathon Delacour for comments on my implementation of keyboard shortcuts).


Features

Cross-version compatibility

These "janus" macros run unmodified in both version 3.25 and version 4 (NisusWriter). You do NOT need to run the Nisus Writer conversion macro. They have been tested on 3.25 Nisus and 4.05 NisusWriter. Please notify the author if there are problems running on versions in-between these.

Support for non-contiguous selections!

Probably the most powerful feature of these macros is that they are designed to support Nisus' non-contiguous selections. eg. using command-option selections, or a find command, to select all your level 2 headings, then simply execute the <h2> macro. All the selected headings will now be wrapped with h2 tags.

Supports all commonly used style tags (except forms)

Includes:

Form tags not supported yet.

Flexible support for all list types

Includes: individual marking of list items (<li> tag only), list wrapper tags only for <ol>, <ul>, <dl> type lists, or wrappers as well as list item marking in one command. Two discursive list macros provided to enable dt/dd parts to be delimited by tabs or returns. Includes a macro to quickly convert all bulleted paragraphs to html unordered lists (sorry, no smart list nesting yet).

Supplies oft-neglected end para and list tags

These macros impose <p></p> and <li></li> syntax so your html won't break when browsers start conforming to the html DTD specs. Includes a macro to quickly convert all non-tagged or non-bulleted paragraphs to html paragraphs.

Support for header/footer templates

Three template macros are supplied. One inserts a header at the top of a document and prompts for a title and h1 string. One inserts a standard footer at the bottom of a document. The other simply calls the other two.

Please customise these macros as required to suit yourself.

Powerful aids for generating hypertext tables of contents

The <Head Contents> macro generates properly nested unordered lists of all h2-6 tags in a document, including auto-calculated anchor names on headings, hypertext links on the contents items, and places the result in the clipboard for you to copy into your document (very useful for a Table of Contents section). The <Multifile Head Contents> macro works as per <Head Contents> except it works on all the files selected in the catalog window, creates a new file, and includes the level 1 heading. Again, proper hypertext referencing is done for you.

Optional Styled Tags

Version 2 implements, optionally, automatic styling of tags and tagged text. This feature is not, I repeat not, intended to make these macros into a Web browser! The styles are totally brain-dead when it comes to embedded lists. Please use a proper Web browser to see what your HTML will actually look like. The intention is to provide some basic visual editing assistence.

Installation of Keyboard Shortcuts

No doubt everyone is sick of setting up their shortcuts again for NisusWriter4. For your convenience, a separate macro is supplied to install keyboard shortcuts for each macro name. This works by mirroring the macro names in the actual macro file, and supplying macro code to setup shortcuts.

Simply open the macro file named HTML Keyboard Shortcuts Setup and execute the macro named <aaMake Shortcuts> the default shortcuts are assigned.

The OPTION key is used as the modifier eg.

This is easily changed in the macro itself. You only need run this once of course.


Guide to Styled Mode editing

If you choose to work in styled mode, it is very important you understand how the styles have been implemented. For best results, please take the time to read the following documentation.

WARNING: when you run *Apply HTML styles, the styles applied are NOT ADDITIVE and will replace any existing formatting. If you are working with a document containing your own stylenames or formatting which you want to retain, do NOT use the styled HTML mode (ie. execute *HTML Styles OFF in Macros) and do NOT execute *Apply HTML styles.

Changing to/from styled editing mode

You may switch modes at any time by running *HTML Styles ON in Macros or *HTML Styles OFF in Macros as required. In all appropriate replace commands, styles exist in the replace text. With styled mode ON, the replacement is attribute sensitive - this will import and apply the stylename. With styled mode OFF the replacement is not attribute sensitive.

When working in styled mode, over time the styles will fragment. This can be minimised if you assign a function key to the *normal style, and remember to press that key when adding text to the right of an opening HTML tag.

You can run *Apply HTML Styles at any time to clean up the fragmentation.

Default Styles and their Attributes

A minimal set of defined character stylenames exist in the macro sheet (there is no use of rulers in these styles):

*anchor
The anchor text seen in a hyperlink
Distributed as: Blue, Underline, Additive.

*em
The logical HTML style for emphasis
Distributed as: Italic, Not Additive.

*H1-6 (one for each heading level)
The six HTML heading levels.
Distributed as: Plain, Palatino, Black, Not Additive.

*normal
"Normal" text. When you *Apply HTML styles, everything is first reset to this.
Distributed as: Plain, Palatino, Black, Not Additive, 12 point.

*pre
this style is applied to <pre>, <code> and <tt> tags.
Distributed as: Courier, 10 point, Additive (so you don't lose other styles when you wrap stuff in <pre> tags.

*strong
the logical HTML style for strong emphasis.
Distributed as: Bold, Not Additive.

*tag
all HTML tags ie. anything between angle brackets but excluding what is contained by the opening and closing HTML tags.
Distributed as: Plain, Monaco, Green, Not Additive, 9 point, Ignore Spelling.
Note: You may wish to make this style Invisible.

Changing the defined style attributes

The distributed macro file can be edited to reflect your own stylistic choices but you should not change the additive attributes on any styles. Edit the macro file and select Define Style. Choose the style to change, make and save your changes.

If you change your mind later, the macro *Kill HTML stylenames should be run, followed by *Apply HTML styles, on any documents edited with your prior style formatting choices in order to bring them back in sync with the macro's formatting choices.

How to see your HTML without tags

Several options are available in these macros.
Make the *tag style invisible
Advantages: it is very fast to use Nisus' menu item for display or non-display of visible text, especially if you assign that menu item a short-cut. Disadvantages: Its very easy to be confused when editing with invisible text hidden - the tags will not appear. It is strongly suggested that you always display invisible text when editing.

Use the *Visible HTML Tags Toggle macro
Advantages: *tag style may be kept as visible, so they will always appear when editing. Disadvantages: on large documents it may take some time to execute the formatting change.

Use the *HTML to Text macro
Advantages: reasonably fast. Disadvantages: Creates another file.

Frankly, MOH the best option is to save your work and view it in a Web browser!

Design issues

When implementing HTML styles in these macros, a critical design decision was whether or not to make the HTML stylenames additive. Additive character styles would have the advantage of better coexisting with existing non-HTML related formatting. This is important if users want a single document suitable for hardtop and Web format, and they want additional formatting beyond the scope of html tags in the print version and have used styles to achieve this. On the other hand, without additive styles there would be no way of ensuring a consistent output from the macro which applies HTML styles. For example, with additive styles, running *Apply HTML styles a second time would actually remove the HTML styles. To get consistent output, one needs to apply formatting from a consistent base. This means killing all existing formatting.

In this release I have chosen in favour of consistency of output ie. I have implemented NON-additive HTML styles. The fact that applying HTML styles will kill any existing formatting is a conscious design choice - don't say you weren't warned! My sincere apologies if this disappoints you, but you can still make excellent use of these macros by simply using them in non-styled mode. In this case, no attributes are changed in replacements. I am painfully aware that as the designer I am imposing my own preferences. I can only say that for future releases I am receptive to expressed user opinion on whether this should change. You are of course free to make the macro's stylenames NON-additive but be warned you may be surprised with the results.


The HTML Markup Macros in detail


Macros to manage styled editing mode

Note: I have chosen not to include any keyboard short-cuts for these style related macros in the distribution because their use and combinations will be very personal.

    *Add HTML styles to Doc            *Kill HTML stylenames 
    *Apply HTML styles                 *Remove ALL formatting 
    *HTML Styles OFF in Macro          *Remove HTML Styles 
    *HTML Styles ON in Macros          *Visible HTML Tags Toggle  
    *HTML to Text                      *No spell unstyled tags

*Add HTML styles to Doc
Force the macro stylenames to be present in the document (does not apply them).

*Apply HTML styles
This macro will apply the macro stylenames to all HTML tags and text. WARNING: THIS MACRO REMOVES ALL OTHER STYLENAMES AND FORMATTING from the text and leaves only the HTML formatting styles. There is a warning dialogue to this effect - reply yes to continue. These styles are controlled by the formatting choices defined in the macrosheet. The macro does alot of processing and runs very slowly on large HTML documents.

*HTML Styles OFF in Macros
Modifyies and saves the macro file so that styles are not applied when executing HTML tag macros. This in effect provides a plain text editing mode. The macros are distributed in this mode ie Styles OFF.

*HTML Styles ON in Macros
Modifies and saves the macro file so that styles will be applied when executing HTML tag macros.

*HTML to Text
Selects all text which is not in HTML tags, copies it to a new file suffixed with .txt instead of .html.

*Kill HTML stylenames
Removes the HTML stylenames from a document's style menu. Useful for reverting to plain text mode, or bringing a documents styles back in sync with the macro stylename formats if you are getting Nisus style conflict dialogues.

*No spell unstyled tags
For those who prefer unstyled editing, but still want to avoid spelling checks on the tags. It implements this by selecting all the tags, invoking the dictionary dialogue and keying cmd-M for Ignore. The macro only works if styled editing is off, as it is assumes that if you use styles you will want to retain no spelling on the *tag style.

*Remove ALL formatting
Make everything plain text - effectively removes all style formatting (but not defined stylenames) from the document.

*Remove HTML Styles
Selects text by HTML style and undoes the style by re-applying it for each defined html stylename. Written to assist in debugging style choices but not really useful other than as a model for your own find commands based on the styles.

*Visible HTML Tags Toggle
This macro simply selects all HTML tags and toggles the visible text attribute on or off. It does not modify the named style attributes of the *tag defined style. Very useful if you retain the visible attribute on your *tag style.
Shortcut: cmd-opt-vt.


HTML tag macros

This section describes what each macro concerned with inserting HTML markup tags does.

Note:

  1. all macros support non-contiguous selections unless otherwise noted.
  2. & indicates whatever is selected when the macro is executed.
<ADdress>  <Anchor...>  <aTEMplate document...>  <aTemplate Footer...>  
<aTemplate Header...>  <B>  <BlockQuote>  <BR>  <CEnter> Netscape  
<CIte>  <Code>  <DD>  <DL> Returns delim  <DL> Tabs delim  <DL> Wrapping only  
<DT>  <DotPoints to Ulists>  <EM>  <FOnt...> Netscape  <H1>  <H2>  <H3>  
<H4>  <H5>  <H6>  <Head Contents>  <Href...>  <Href...> Internal link  
<HR>  <I>  <IMG...>  <ISO translate>  <ISo trans Inc <> tags>  
<Kill html>  <Kill P in Pre>  <LI>  <Multifile Head Contents>  
<OL>  <OL> Wrapping only  <P>  <PRE>  <Returns to Paras>  <strIKe>  
<STrong>  <Title>  <TT>  <U>  <UL>  <UL> Wrapping only

<ADdress>
Wraps selection(s) with <address>&</address>.
Shortcut: cmd-opt-ad.

<Anchor...>
Wraps selection(s) with <a name="&">&</a>.
Shortcut: cmd-opt-a.

<aTEMplate document...>
Inserts header and footer at top and bottom respectively, and prompts for a title.
Shortcut: cmd-opt-tem.

<aTemplate Footer...>
Inserts footer html at bottom of file.
Shortcut: cmd-opt-tf.

<aTemplate Header...>
Inserts header html at bottom of file, and prompts for a title..
Shortcut: cmd-opt-th.

<B>
Wraps selection(s) with <b>&</b>.
Shortcut: cmd-opt-b.

<BlockQuote>
Wraps selection(s) with <blockquote>&</blockquote>.
Shortcut: cmd-opt-bq.

<BR>
Inserts a line break <br> tag at the insertion point (non-contiguous selections make no sense here).
Shortcut: cmd-opt-br.

<CEnter> Netscape
Simple implementation of Netscape's <centre>...</center> tag.
Shortcut: cmd-opt-ce.

<CIte>
Wraps selection(s) with <cite>&</cite>.
Shortcut: cmd-opt-ci.

<Code>
Wraps selection(s) with <code>&</code>.
Shortcut: cmd-opt-c.

<DD>
Wraps selection(s) with <dd>&</dd>.
Shortcut: cmd-opt-dd.

<DL> Returns delim
Wraps selection(s) with <dl>&</dl> and for each pair of lines, wraps first in <dt></dt> and second in <dd></dd> (nb: return delimited).
Shortcut: cmd-opt-dlr.

<DL> Tabs delim
Wraps selection(s) with <dl>&</dl> and for each pair of data with a tab in between, wraps first field in <dt></dt> and second in <dd></dd> (nb: tab delimited).
Shortcut: cmd-opt-dlt.

<DL> Wrapping only
Wraps selection(s) with <dl>&</dl>.
Shortcut: cmd-opt-dlw.

<DT>
Wraps selection(s) with <dt>&</dt>.
Shortcut: cmd-opt-dt.

<DotPoints to Ulists>
Convert all paras in curr seln(s) which start with a bullet, dash, tab, asterisk (ie. characters likely to be used for lists) to html list items, ignoring leading spaces, and removing the list character. Does NOT handle indented lists (single level only).
Shortcut: cmd-opt-dpu.

<EM>
Wraps selection(s) with <em>&</em>.
Shortcut: cmd-opt-em.

<FOnt...> Netscape
Simple implementation of Netscape's <font size=N>...</font> tag.
Shortcut: cmd-opt-fo.

<H1>
Wraps selection(s) with <h1>&</h1>.
Shortcut: cmd-opt-h1.

<H2>
Wraps selection(s) with <h2>&</h2>.
Shortcut: cmd-opt-h2.

<H3>
Wraps selection(s) with <h3>&</h3>.
Shortcut: cmd-opt-h3.

<H4>
Wraps selection(s) with <h4>&</h4>.
Shortcut: cmd-opt-h4.

<H5>
Wraps selection(s) with <h5>&</h5>.
Shortcut: cmd-opt-h5.

<H6>
Wraps selection(s) with <h6>&</h6>.
Shortcut: cmd-opt-h6.

<Head Contents>
Auto-generates a table of contents for all headings in the current file, and places it in the clipboard. WARNING: This macro calculates and assigns its own anchor names on all heads, thus overwriting any anchors you may have assigned. Don't say you weren't warned! It retains any hrefs which already exist in the heading (bug fixed in version 1.2). It ignores any text following end heading tags (bug fixed in version 1.3).

<Href...>
Wraps selection(s) with <a href="XXXXXXX.html">&</a> and highlights the XXXXXXX.html (so you can easily paste a URL if you have it in the clipboard).
Shortcut: cmd-opt-h.

<Href...> Internal link
Wraps selection(s) with <a href="#&">&</a> and highlights the anchor name so you can easily modify it.
Shortcut: cmd-opt-hi.

<HR>
Inserts a tab followed by <hr> at start of all selections. Also displays a line across the screen using a named ruler and a tab mark with leading. To modify the rulers appearence, change the ruler present in the xxxRulersOnHRs macro. Modified to support non-contiguous selection in Version 2, so now its easy to use Nisus to select, say, all <h2> tags and insert a horizontal rule in front of all level 2 headings.
Shortcut: cmd-opt-hr.

<I>
Wraps selection(s) with <i>&</i>.
Shortcut: cmd-opt-i.

<IMG...>
Inserts inline image tags, for example: <img src="GGGGGGGG.gif" align=BOTTOM alt="&">
Shortcut: cmd-opt-img.

<ISO translate>
In current selection(s), translate non html tag special chars to their equivalent html entities (ie. not < or > - see below). Currently only converts "&" to "&amp;", but is easily extended.
Shortcut: cmd-opt-iso.

<ISo trans Inc <> tags>
In current selection(s), translate html tag chars < and > to their equivalent html entities.
Shortcut: cmd-opt-isi.

<Kill html>
Removes html from selections.
Shortcut: cmd-opt-k.

<Kill P in Pre>
Removes html paragraph tags within preformatted text. Thanks to Matthew Xavier Mora for suggesting this.
Shortcut: cmd-opt-kp.

<LI>
Wraps selection(s) with <li>&</li>.
Shortcut: cmd-opt-li.

<Multifile Head Contents>
As per <Head Contents> except it works on files currently selected in the catalog. WARNING: This macro calculates and assigns its own anchor names on all heads, thus overwriting any anchors you may have assigned. Don't say you weren't warned!
Shortcut: cmd-opt-hc.

<OL>
Wraps selection(s) with <ol>&</ol> and for line wraps it in <li></li>.
Shortcut: cmd-opt-ol.

<OL> Wrapping only
Wraps selection(s) with <ol>&</ol>.
Shortcut: cmd-opt-olw.

<P>
If nothing is selected, inserts <p> at the insertion point. Otherwise, wraps selections in <p></p>.
Shortcut: cmd-opt-p.

<PRE>
Wraps selection(s) with <pre>&</pre> and applies a monospaced font.
Shortcut: cmd-opt-pre.

<Returns to Paras>
For the current selection(s), convert all returns to paragraph html so long as the para doesn't start with a html tag, bullet, dash, tab, asterisk (that probably signifies a list item). Also changes any soft-returns to <br>. Use in conjunction with the Unbreak lines macro (see below).
Shortcut: cmd-opt-rp.

<strIKe>
Wraps selection(s) with <strike>&</strike>.
Shortcut: cmd-opt-ik.

<STrong>
Wraps selection(s) with <strong>&</strong>.
Shortcut: cmd-opt-st.

<Title>
Wraps selection(s) with <title>&</title>.
Shortcut: cmd-opt-t.

<TT>
Wraps selection(s) with <tt>&</tt>.
Shortcut: cmd-opt-tt.

<U>
Wraps selection(s) with <u>&</u>.
Shortcut: cmd-opt-u.

<UL>
Wraps selection(s) with <ul>&</ul> and for line wraps it in <li></li>.
Shortcut: cmd-opt-ul.

<UL> Wrapping only
Wraps selection(s) with <ul>&</ul>.
Shortcut: cmd-opt-ulw.


Other Convenience Macros

The package includes a number of other macros not specifically concerned with HTML tags, but of convenience to HTML authors.

Add Marker  Clean up returns  Copy Open Pathnames  Copy Pathname  
Create Anchor List  Delete Rulers  Find selection  Extract RTF Stylesheet  
Select All HTML  Select All Not HTML  Select HTML  Select Not HTML  
Unix->Mac text  Unbreak Lines    
Add Marker
This macro is exactly the same as "Mark" in Nisus but it works on non-contiguous selections.

Clean up returns
Removes multiple returns and inserts an extra return at the start of a genuine HTML paragraph, heading, list item etc..

Copy Open Pathnames
Copies the full pathnames of all open documents onto the Clipboard. If a macro file is the front document, only the macro file will be found.

Copy Pathname
Copies the full pathname of the current document onto the Clipboard.

Create Anchor List
Creates a new document containing a set of hrefs to all internal anchor names in the current selection (or whole file if nothing selected). Useful for generating internal cross-references.

Delete Rulers
Deletes all rulers (except the first) from the current document.

Find selection
Finds next occurance of the current selection.

Extract RTF Stylesheet
If you open as text an RTF file, this macro extracts out the stylesheet information.

Select All HTML
Selects everything between <> tags. Useful if you want to make HTML invisible, and/or turn off spell checking.

Select All Not HTML
Selects everything not wrapped in HTML tags. Relies on you enclosing your html document in <html>...</html> tags, as you should.

Select HTML
Selects HTML tags within the current selection.

Select Not HTML
Selects everything not wrapped in HTML tags within the current selection.

Unix->Mac text
Changes Unix end of lines to Mac returns.

Unbreak Lines
Remove returns from selected text.

Document a Macro File

I wrote this so I could easily print a macrofile. Copy <Document Macro File> to any macro file, execute it, and it will generate an indexed list of that macro contents (non-displayable special characters are converted to meaningful names).
IMPORTANT: this macro relies on an arbitrary convention of delimiting each macro from another. It uses the convention:
//==================== MACRO macro-name-here
at the start of each macro. The macro file contents are copied, these marker lines are picked up and the names are marked and indexed. You could modify the macro as required to suit your own convention. If you do not use this convention or modify the macro to suit your own, its results will be unpredictable.

Version History

Version 2.0, 8 Mar 1995

Version: 1.3, 27 Dec 1994

Version: 1.2, 14 Dec 1994

Version 1.1 10 Dec 1994

Version 1.0 10 Nov 1994 - Initial version.


Planned Enhancements

Support for forms
I plan to include a form "template" macro, plus macros for commonly used form tags.
Better support for installation of new versions
I want to try to work out a way to let you install new versions but retain your own style preferences. Ideas on how to do this are welcome!

Bug Reports and Comments

I cannot guarantee to support these macros in any way, but I will try to respond to bug reports and improvements as best I can.

Please forward all bug reports, comments, and requests to ssilcot@www.unimelb.edu.au


Silcot's Nisus HTML Macros Read Me (Official "home").
Date created:  Nov 10 1994
Last modified: 8 Mar 1995
Sandra Silcot, Information Technology Services, University of Melbourne. Email: ssilcot@www.unimelb.edu.au WWW: http://www.unimelb.edu.au/~ssilcot/